package com.lingxin.gps.wap.controller;

import com.jfinal.aop.Before;
import com.lingxin.gps.wap.ApiLoginInterceptor;
import com.lingxin.gps.wap.LoginInterceptor;
import com.lingxin.gps.wap.PageLoginInterceptor;
import com.lingxin.gps.wap.command.*;
import com.pisces.core.BaseController;
import com.pisces.core.route.ControllerBind;

/**
 * 用户管理
 */
@ControllerBind(controllerKey = "/user", viewPath = "/user")
public class UserController extends BaseController {

	/**
	 * 登录页面
	 */
	public void login() {
		renderPage("login.html");
	}

	/**
	 * 用户登录
	 */
	public void ajaxLogin() {
		doAction(new CUserLogin());
		renderJson();
	}

	/**
	 * 用户登出
	 */
	@Before(LoginInterceptor.class)
	public void logout() {
		doAction(new CUserLogout());
		renderPage("login.html");
	}

	/**
	 * 获取用户信息
	 */
	@Before(PageLoginInterceptor.class)
	public void info() {
		doAction(new CUserInfo());
		renderPage("edit_info.html");
	}

	/**
	 * 保存用户信息
	 */
	@Before(ApiLoginInterceptor.class)
	public void saveInfo() {
		doAction(new CUserInfoSave());
		renderJson();
	}

	@Before(PageLoginInterceptor.class)
	public void modifyPwdPage() {
		renderPage("edit_pwd.html");
	}

	/**
	 * 修改用户密码
	 */
	@Before(ApiLoginInterceptor.class)
	public void modifyPwd() {
		doAction(new CUserModifyPwd());
		renderJson();
	}


}
